<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}

//$queryString = "SELECT id, name,password,type_id FROM config_user LIMIT 10 OFFSET " . ($_GET["pag"]*10);
$queryString = "SELECT id, name,password,type_id FROM config_user WHERE name LIKE '%".$_GET['word_search']."%' LIMIT 10 OFFSET " . ($_GET["pag"]*10);
$queryString = "SELECT 
  config_user.id, 
  config_user.name, 
  config_user.password, 
  config_usertype.name as type_id
FROM 
  public.config_user, 
  public.config_usertype
WHERE 
  config_user.type_id = config_usertype.id
AND
  config_usertype.name LIKE '%".$_GET['word_search']."%' LIMIT 10 OFFSET " . ($_GET["pag"]*10);

$query = pg_query($connect, $queryString);
if (!$query) {
    echo 'query : ';
    return false;
}
$arrRegistros = pg_fetch_all($query);
echo json_encode($arrRegistros);
$num_fields = pg_num_fields($query);
$num_rows = pg_num_rows($query);

pg_close($connect);
